package test5.lupeng.jf.com.teamdemo.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;

import java.util.ArrayList;

import test5.lupeng.jf.com.teamdemo.R;
import test5.lupeng.jf.com.teamdemo.bean.response.NearPeopleBean;
//第二个按钮的adapter
public class NearListAdapter extends RecyclerView.Adapter<NearListAdapter.LiViewHolder>{
    ArrayList<NearPeopleBean.ResultBean> mResult;

    public NearListAdapter(ArrayList<NearPeopleBean.ResultBean> mResult) {
        this.mResult = mResult;
    }

    @Override
    public NearListAdapter.LiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.item_near,parent,false);
        LiViewHolder holder=new LiViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(NearListAdapter.LiViewHolder holder, int position) {
        Glide.with(holder.itemView.getContext())
                .load(mResult.get(position).getHeadProtrait())
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(holder.iv_nearhead);
        holder.tv_nearname.setText(mResult.get(position).getUsername());
        holder.tv_nearwrite.setError(mResult.get(position).getSignature());
    }

    @Override
    public int getItemCount() {
        return mResult.size();
    }

    class LiViewHolder extends RecyclerView.ViewHolder {

        ImageView iv_nearhead;
        TextView tv_nearname;

        TextView tv_nearwrite;
        public LiViewHolder(View itemView) {
            super(itemView);
            iv_nearhead = itemView.findViewById(R.id.iv_nearhead);
            tv_nearname = itemView.findViewById(R.id.tv_nearname);
            tv_nearwrite = itemView.findViewById(R.id.tv_nearwrite);
        }
    }

}
